package com.bao.work;

import java.util.Scanner;

/**
 * @author baoye
 * @date 2024-07-23/19:26
 */
public class ExceptionTest03 {
    public static void main(String[] args) {
        boolean flag = true;
        while (flag) {
            System.out.println("请输入N");
            int N = new Scanner(System.in).nextInt();
            try {
                flag = false;
                if (N < 0) {
                    throw new Exception("N必须是正数");
                }
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("请重新输入");
                flag = true;
            }
        }
    }


}

